package com.fili.gui.components.graph;

import com.fili.core.params.DryParams;
import com.fili.core.storage.DataItemConfig;
import com.fili.core.storage.DataItemType;
import com.fili.gui.components.table.color.ColorTableListener;

import java.awt.*;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Oct 22, 2006
 * Time: 10:58:00 PM
 */
public class CTListener implements ColorTableListener
{
    private DataGraph dataGraph;

    public CTListener(DataGraph dataGraph)
    {
        this.dataGraph = dataGraph;
    }

    public Color colorTableColorAt(int index)
    {
        return DryParams.getParams().getDataGraphConfig().getColor(DataItemConfig.getItems()[index]);
    }

    public boolean colorTableSelectedAt(int index)
    {
        return DryParams.getParams().getDataGraphConfig().isVisible(DataItemConfig.getItems()[index]);
    }

    public String colorTableTextAt(int index)
    {
        return DataItemType.getType(DataItemConfig.getItems()[index]).getName();
    }

    public void colorTableColorChanged(int index, Color color)
    {
        DryParams.getParams().getDataGraphConfig().setColor(DataItemConfig.getItems()[index], color);
        DryParams.saveParams();
        dataGraph.repaint();
    }

    public void colorTableSelectionChanged(int index, boolean selected)
    {
        DryParams.getParams().getDataGraphConfig().setVisible(DataItemConfig.getItems()[index], selected);
        DryParams.saveParams();
        dataGraph.repaint();
    }
}
